<template>
	<el-form label-width="100px">
		<el-form-item label="绑定组织">
			<el-cascader :options="orgList" clearable :props="orgListProps" size="mini" class="cascader"
				v-model="orgId" disabled></el-cascader>
		</el-form-item>
		<el-form-item label="加点">
			<el-select v-model="orgPointId" size="mini" filterable remote clearable >
				<el-option v-for="item in pointList" :key="item.id" :value="item.id" :label="calcPoint(item.point)">
				</el-option>
			</el-select>
		</el-form-item>
	</el-form>
</template>

<script>
	import { pointList, orgPrice, getOrgList } from '@/api/price.api'
	export default{
		name: "point-org-config",
		data() {
			return {
				pointList:  [],
				orgPointId: "",
				orgListProps: {
					checkStrictly: true,
					value: 'id',
					label: 'name'
				},
				orgList: []
			}
		},
		props: {
			priceId: {
				type: String,
				default: ""
			},
			orgId: {
				type: String,
				default: ""
			}
		},
		mounted() {
		},
		methods: {
			init() {
				this.getPointList();
				this.getOrgList();
				orgPrice(this.priceId, this.orgId).then(res => {
					this.orgPointId = res.point.id
				})
			},
			getPointList() {
				pointList().then(res => {
					this.pointList = res
				})
			},
			getOrgList() {
				getOrgList().then(res => {
					this.orgList = res
				})
			},
			calcPoint(point) {
				return (point/100).toFixed(2) + "%"
			},
		}
	}
</script>

<style>
</style>